package com.cashmama.market.api.application.controller.user.response;

import com.cashmama.market.api.domain.vo.user.UserActivityPopupVO;
import com.cashmama.market.api.infras.handler.ResponseData;
import com.cashmama.market.api.infras.utils.TextFormatUtil;
import com.google.common.collect.Lists;
import com.qianli.cashmama.trade.client.trade.response.TradeInfoRO;

import java.math.BigDecimal;
import java.util.List;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-04-16 17:19
 **/
public class UserActivityPopupResponse implements ResponseData {

    /**
     * 1-ddd 签到弹窗
     * 2-提现提醒弹窗
     */
    private Integer popupType;

    private Object popupInfo;

    private Long popupId;
    private String imageUrl;
    private String url;
    private String buttonText;

    public UserActivityPopupResponse(UserActivityPopupVO userActivityPopup) {
        this.popupId = userActivityPopup.getPopupId();
        this.imageUrl = userActivityPopup.getImageUrl();
        this.url = userActivityPopup.getUrl();
        this.buttonText = userActivityPopup.getButtonText();
    }

    public UserActivityPopupResponse(TradeInfoRO tradeInfoRO) {
        this.popupType = 2;
        Item2 item2 = new Item2();
        item2.setPopupId(0L);
        item2.setText1(TextFormatUtil.format("Congratulations, the loan of ₹{amount} was approved.", new BigDecimal(tradeInfoRO.getBorrowTotalCapital()).setScale(0, BigDecimal.ROUND_HALF_UP).toPlainString()));
        item2.setHighlightTextList(Lists.newArrayList("₹" + new BigDecimal(tradeInfoRO.getBorrowTotalCapital()).setScale(0, BigDecimal.ROUND_HALF_UP).toPlainString()));

        String cardNo = tradeInfoRO.getCardNo().substring(0, 3) + "****" + tradeInfoRO.getCardNo().substring(tradeInfoRO.getCardNo().length() - 4);
        item2.setText2(TextFormatUtil.format("Bank Account No. {cardNo}", cardNo));
        item2.setButtonText("Withdraw Right Now");
        item2.setTradeNo(tradeInfoRO.getTradeNo());
        this.popupInfo = item2;
    }

    public Integer getPopupType() {
        return popupType;
    }

    public UserActivityPopupResponse setPopupType(Integer popupType) {
        this.popupType = popupType;
        return this;
    }

    public Object getPopupInfo() {
        return popupInfo;
    }

    public UserActivityPopupResponse setPopupInfo(Object popupInfo) {
        this.popupInfo = popupInfo;
        return this;
    }

    public Long getPopupId() {
        return popupId;
    }

    public UserActivityPopupResponse setPopupId(Long popupId) {
        this.popupId = popupId;
        return this;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public UserActivityPopupResponse setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public UserActivityPopupResponse setUrl(String url) {
        this.url = url;
        return this;
    }

    public String getButtonText() {
        return buttonText;
    }

    public UserActivityPopupResponse setButtonText(String buttonText) {
        this.buttonText = buttonText;
        return this;
    }

    private static class Item1 {
        private Long popupId;
        private String imageUrl;
        private String url;
        private String buttonText;

        public Long getPopupId() {
            return popupId;
        }

        public Item1 setPopupId(Long popupId) {
            this.popupId = popupId;
            return this;
        }

        public String getImageUrl() {
            return imageUrl;
        }

        public Item1 setImageUrl(String imageUrl) {
            this.imageUrl = imageUrl;
            return this;
        }

        public String getUrl() {
            return url;
        }

        public Item1 setUrl(String url) {
            this.url = url;
            return this;
        }

        public String getButtonText() {
            return buttonText;
        }

        public Item1 setButtonText(String buttonText) {
            this.buttonText = buttonText;
            return this;
        }
    }

    private static class Item2 {
        private Long popupId;
        /**
         * 文字
         */
        private String text1;

        private List<String> highlightTextList;

        private String text2;

        private String buttonText;

        private String tradeNo;

        public Long getPopupId() {
            return popupId;
        }

        public Item2 setPopupId(Long popupId) {
            this.popupId = popupId;
            return this;
        }

        public String getText1() {
            return text1;
        }

        public Item2 setText1(String text1) {
            this.text1 = text1;
            return this;
        }

        public List<String> getHighlightTextList() {
            return highlightTextList;
        }

        public Item2 setHighlightTextList(List<String> highlightTextList) {
            this.highlightTextList = highlightTextList;
            return this;
        }

        public String getText2() {
            return text2;
        }

        public Item2 setText2(String text2) {
            this.text2 = text2;
            return this;
        }

        public String getButtonText() {
            return buttonText;
        }

        public Item2 setButtonText(String buttonText) {
            this.buttonText = buttonText;
            return this;
        }

        public String getTradeNo() {
            return tradeNo;
        }

        public Item2 setTradeNo(String tradeNo) {
            this.tradeNo = tradeNo;
            return this;
        }
    }

}
